<?php
    defined( 'BASEPATH' ) OR exit( 'No direct script access allowed' );

    class Navigate extends Admin_Controller
    {
        /**
         * 左侧栏位
         */
       /* public function getChildList()
        {
            #接受参数
            $pid = $this->input->get( 'id' );
            $this->load->model( "admin/navigate_model" );
            $data[ 'navigate' ] = $this->navigate_model->getList( $pid );
            $this->load->view( "navigate/child", $data );
        }*/
       /* public function getThirdList()
        {
            #接受参数
            $pid = $this->input->get( 'id' );
            $this->load->model( "admin/navigate_model" );
            $data[ 'navigate' ] = $this->navigate_model->getChildList( $pid );
            $this->load->view( "navigate/third", $data );
        }*/
       /* public function selectTree(){
            $this->load->model( "admin/navigate_model" );
            $list = $this->navigate_model->getAllList();
            $list=$this->tree($list);
            array_unshift($list,array('id'=>0,'text'=>'顶级菜单'));
            exit(json_encode($list));
        }*/
        public function tree($arr,$pid='0') {
            $tree = array();
            foreach($arr as $row){
                //$row['state']="closed";
                //$row['text']=$row['title'];
                if($row['pid']==$pid){
                    $tmp = $this->tree($arr,$row['id']);
                    if($tmp){
                        $row['children']=$tmp;
                    }else{
                        $row['leaf'] = true;
                    }
                    $tree[]=$row;
                }
            }
            return $tree;
        }

        /**
         * 得到｜｜|_这样的下拉
         */
        public function getTree()
        {
            $id = $this->input->get( 'id' );
            $this->load->model( "admin/navigate_model" );
            $navigate = $this->navigate_model->getTree( $id );
            echo $navigate;
        }
        public function save()
        {
            
        }
        public function delete(){
            $ids = $this->input->post( 'ids' );
            $this->load->model('admin/navigate_model');
            $isok=$this->navigate_model->delete($ids);
            return $isok;
        }
        public function testUploadImg()
        {
            exit("eeee");
        }

    }
